import axios from 'axios';
import {
  {{ pascal_case }}DTO,
  {{ pascal_case }}Query,
  {{ pascal_case }}VO,
  Result{{ pascal_case }},
  ResultPage{{ pascal_case }}VO,
} from './{{kebab_case}}';

const BASE_URL = '/api/account/{{ kebab_case }}';
/**
 * 查询分页
 */
export function page(params: {{ pascal_case }}Query) {
  return axios.get<{{ pascal_case }}VO[], ResultPage{{ pascal_case }}VO>(BASE_URL, { params });
}
/**
 * 查询单个
 */
export function getById(id: string) {
  return axios.get<{{ pascal_case }}VO, Result{{ pascal_case }}>(`${BASE_URL}/${id}`);
}
/**
 * 新增或修改
 */
export function addOrModify(data: {{ pascal_case }}DTO) {
  if (data.id) {
    return axios.put<Response>(`${BASE_URL}`, data);
  }
  return axios.post<Response>(`${BASE_URL}`, data);
}
/**
 * 批量删除
 */
export function del(ids: [string | undefined]) {
  return axios.delete<Response>(`${BASE_URL}`, { params: { ids } });
}
